/*
 * Powered By dico
 * Since 2017 - 2018
 */package com.seeyoui.kensite.bussiness.exam.question.service;
 
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.seeyoui.kensite.bussiness.exam.question.domain.Question;
import com.seeyoui.kensite.bussiness.exam.question.domain.QuestionVO;
import com.seeyoui.kensite.bussiness.exam.question.persistence.QuestionMapper;
import com.seeyoui.kensite.common.base.service.BaseService;
import com.seeyoui.kensite.common.exception.CRUDException;

/**
 * Question
 * @author dico
 * @version 2.0
 * @since 1.0
 * @date 2018-01-07
 */

@Service
public class QuestionService extends BaseService {
	
	@Autowired
	private QuestionMapper questionMapper;

	/**
	 * 根据ID查询单条数据
	 * @param id
	 * @return
	 * @throws CRUDException
	 */
	public Question findOne(String id) throws CRUDException{
		return questionMapper.findOne(id);
	}
	
	/**
	 * 查询数据集合
	 * @param question
	 * @return
	 * @throws CRUDException
	 */
	public List<Question> findList(Question question) throws CRUDException {
		return questionMapper.findList(question);
	}
	
	/**
	 * 查询所有数据集合
	 * @param question
	 * @return
	 * @throws CRUDException
	 */
	public List<Question> findAll(Question question) throws CRUDException {
		return questionMapper.findAll(question);
	}
	
	/**
	 * 查询数据总数
	 * @param question
	 * @return
	 * @throws CRUDException
	 */
	public int findTotal(Question question) throws CRUDException {
		return questionMapper.findTotal(question);
	}
	
	/**
	 * 查询数据总数排除当前数据
	 * @param question
	 * @return
	 * @throws CRUDException
	 */
	public int findExTotal(Question question) throws CRUDException {
		return questionMapper.findExTotal(question);
	}
	
	/**
	 * 数据新增
	 * @param question
	 * @throws CRUDException
	 */
	public void save(Question question) throws CRUDException{
		question.preInsert();
		questionMapper.save(question);
	}
	
	/**
	 * 数据修改
	 * @param question
	 * @throws CRUDException
	 */
	public void update(Question question) throws CRUDException{
		question.preUpdate();
		questionMapper.update(question);			
	}
	
	/**
	 * 数据删除
	 * @param listId
	 * @throws CRUDException
	 */
	public void delete(List<String> listId) throws CRUDException {
		questionMapper.delete(listId);
	}
	
	/**
	 * 数据假删除
	 * @param question
	 * @throws CRUDException
	 */
	public void remove(Question question) throws CRUDException{
		question.preUpdate();
		questionMapper.remove(question);			
	}
	
	/**
	 * 按题库ID和试题类型ID查询QuestionVO列表
	 * @param question
	 * @return
	 * @throws CRUDException
	 */
	public List<QuestionVO> findByLibraryIdAndTypeId(Question question) throws CRUDException {
		return questionMapper.findByLibraryIdAndTypeId(question);
	}
}